package io.renren.modules.member.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.renren.modules.member.entity.ExamMiddleHistoryEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface ExamMiddleHistoryDao extends BaseMapper<ExamMiddleHistoryEntity> {

    @Select("<script>" +
            "SELECT " + ExamMiddleHistoryEntity.SQL_COLUMN + " FROM exam_middle_history " + 
            "<where> " +
            " <if test=\"name != null and name !=''\"> " +
            " AND t.name like CONCAT(#{name},'%'); " +
            " </if>" +
            " <if test=\"examDate != null and examDate !=''\"> " +
            " AND exam_date = #{examDate} " +
            " </if>" +
            " <if test=\"studentCode != null and studentCode !=''\"> " +
            " AND student_code = #{studentCode} " +
            " </if>" +
            "</where>" +
            " ORDER BY id DESC LIMIT #{showNumber} " +
            "</script>")
    List<ExamMiddleHistoryEntity> findAllLast(Map<String, Object> param);
}
